﻿using PelitaProduksi.View;
using PelitaProduksi.View.Panel;
using PelitaProduksi.View.Panel.Master;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PelitaProduksi
{
    public partial class Main : Form
    {
        Login LOGIN;
        public Dictionary<int, Form> LIST_FORMS;
        public int CODE;
        public string USER;
        public Main(Login l, string user)
        {
            InitializeComponent();
            LIST_FORMS = new Dictionary<int, Form>();
            CODE = 0;
            this.LOGIN = l;
            this.USER = user;
            this.welcome.Text = string.Format("SELAMAT DATANG  [{0}]", USER);
        }

        private void windowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void closed(object sender, FormClosedEventArgs e)
        {
            LOGIN.Close();
        }

        private void timerWaktu_Tick(object sender, EventArgs e)
        {
            time.Text = DateTime.Now.ToShortTimeString();
        }


        private void baruToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormRajut rajut = new FormRajut(this, CODE);
            LIST_FORMS.Add(CODE++, rajut);
            rajut.Activate();
            rajut.BringToFront();
            rajut.Visible = true;
        }

        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchRajut rajut = new SearchRajut(this, CODE);
            LIST_FORMS.Add(CODE++, rajut);
            rajut.Activate();
            rajut.BringToFront();
            rajut.Visible = true;
        }

        private void karyawanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MasterKaryawan master = new MasterKaryawan(this, CODE);
            LIST_FORMS.Add(CODE++, master);
            master.Visible = true;
            master.Activate();
            master.BringToFront();
        }

        private void perusahaanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MasterUser master = new MasterUser(this, CODE);
            LIST_FORMS.Add(CODE++, master);
            master.Visible = true;
            master.Activate();
            master.BringToFront();
        }

        private void sarungTanganToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MasterBarang master = new MasterBarang(this, CODE);
            LIST_FORMS.Add(CODE++, master);
            master.Visible = true;
            master.Activate();
            master.BringToFront();
        }

        private void userToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MasterCustomer master = new MasterCustomer(this, CODE);
            LIST_FORMS.Add(CODE++, master);
            master.Visible = true;
            master.Activate();
            master.BringToFront();
        }
    }
}
